package Server.junit;

import Server.map.Box;
import Server.map.MeatExhaustedException;
import junit.framework.TestCase;

public class BoxTest extends TestCase {

	private Box b1;
	private Box b2;
	protected void setUp() throws Exception {
		super.setUp();
		this.b1 = new Box(0, 0, false);
		this.b2 = new Box(1, 1, true);
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testGetX() {
		assertTrue(this.b1.getX() == 0);
		assertTrue(this.b2.getX() == 1);
	}

	public void testGetY() {
		assertTrue(this.b1.getY() == 0);
		assertTrue(this.b2.getY() == 1);
	}

	public void testBoxIntIntBoolean() {
		Box b3 = new Box(0, 0, false);
		assertEquals(this.b1, b3);
	}

	public void testBoxBox() {
		Box b3 = new Box(this.b1);
		assertEquals(this.b1, b3);
	}

	public void testIsWater() {
		assertFalse(this.b1.isWater());
		assertTrue(this.b2.isWater());
	}

	public void testIsMeatBox() {
		assertFalse(this.b1.isMeatBox());
		assertFalse(this.b2.isMeatBox());
		this.b1.putMeat();
		assertTrue(this.b1.isMeatBox());
	}

	public void testIsVegetableBox() {
		assertFalse(this.b1.isVegetableBox());
		assertFalse(this.b2.isVegetableBox());
		this.b1.putVegetable();
		assertTrue(this.b1.isVegetableBox());
	}

	public void testUpdateFoodEnergy() {
		this.b1.putMeat();
		int a = this.b1.getFoodEnergy();
		try{
			this.b1.updateFoodEnergy();
		} catch (MeatExhaustedException e){
			assertTrue(this.b1.getFoodEnergy() == 0);
		}
		assertFalse(a == this.b1.getFoodEnergy());
	}

	public void testFoodEaten() {
		this.b1.putMeat();
		this.b1.foodEaten();
		assertTrue(this.b1.getFoodEnergy() == 0);
	}

}
